<html><head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>橘子屋</title>
    <link rel="stylesheet" type="text/css" href="/backpage/css/shoujidd_sj.css">
    <link rel="stylesheet" type="text/css" href="/backpage/css/tongyongbao.css">
    <script src="/backpage/js/tongyongbao.js" type="text/javascript" charset="utf-8"></script><meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">
    <script src="/backpage/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>

    <script src="/backpage/assets/layer/layer.js" type="text/javascript"></script><link rel="stylesheet" href="/backpage/assets/layer/skin/layer.css" id="layui_layer_skinlayercss" style="">
    <script src="/backpage/assets/laydate/laydate.js" type="text/javascript"></script><link type="text/css" rel="stylesheet" href="/backpage/assets/laydate/need/laydate.css"><link type="text/css" rel="stylesheet" href="/backpage/assets/laydate/skins/default/laydate.css" id="LayDateSkin">
    <script src="/backpage/assets/js/jquery.easy-pie-chart.min.js"></script>
    <script src="/backpage/assets/layer/extend/layer.ext.js"></script>

</head>
<body>
<header>
    <a href="javascript:history.back(-1)"><img src="/backpage/images/zuojiantou.png" class="zuojiantou"></a>

    橘子屋-{{$info->statuses}}订单
</header>
<div class="dd_bianhao">
    <span>订单编号:</span>
    <div>{{$info->orders_number}}</div>
</div>
<div class="sjr_xx">
    <div class="sjrxx_bt">
        &nbsp;&nbsp;收件人信息
    </div>
    <div class="sjrxx_lxfs">
        <span>姓名:</span>
        <div>{{$info->address->name}}</div>
    </div>
    <div class="sjrxx_lxfs2">
        <span>手机号码:</span>
        <div><a href="tel:{{$info->address->mobile}}">{{$info->address->mobile}}</a></div>
    </div>
    <div class="sjrxx_lxfs3">
        <span>收货地址/邮编:</span>
        <div>{{$info->address->address}} / {{$info->address->code}}</div>
    </div>
</div>
<div class="cpxx">
    <div class="cpxx_bt">
        &nbsp;&nbsp;产品信息
    </div>
@php
$total = 0;
@endphp
@foreach($info->orders_goods as $k=>$row)
        <div class="zfdd">
            <ul>
                <li class="li3">
                    <img src="{{url('upload/'.$row->good->thumb)}}">
                </li>
                <li class="li4"><span>×1.0</span>

                    <span class="z_fudong">{{$row->good->title}} </span>&nbsp;&nbsp;<span class="z_fudong1">{{$row->good_attr->name}}</span><br><span class="jiage_3">￥{{$row->good_attr->price}}</span></li>
                <div class="shanchu" detail="{{$row->id}}">
                    <img src="/backpage/images/shanchu.png">
                </div>
            </ul>
            <div class="biezhu">
                <span>备注:{{$row->content}}</span>
                <div></div>
            </div>
        </div>
        @php
        $total += $row->good_attr->price*$row->goods_num;

        @endphp
@endforeach





    <div class="dd_rq">
        <span>订单生成日期:</span>
        <div>{{$info->created_at->toDateString()}}</div>
    </div>
    <div class="zongshu">
        <div class="zongshu_1">
            <span>总数:</span>
            <div>{{$k+1}}</div>
        </div>
        <div class="zongshu_2">
            <span>总价:</span>
            <div>{{$total}}</div>
            <span class="danwei">元</span>
        </div>
        <div></div>
    </div>
    <div class="qr_qx">
@if($info->status == 0)
            <div id="s1">确认接单</div>
            <div id="s4">取消接单</div>
@elseif($info->status == 2)
  <div id="s3">确认发货</div>
@endif

    </div>

</div>


        <input type="hidden" value="{{$info->type}}" name="buyway" id="buyway"> <!-- 线上 -->


    <input type="hidden" value="{{$info->orders_number}}" name="oid" id="oid"> <!-- 线下 -->




<script>
  $(function(){
    $.ajaxSetup({
  	    headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' }
  	});
  })
    $("#s1").click(function () {    //确认
        var oid = $("#oid").val();
        //console.log("aaaaaaaaaaaaa");
        layer.prompt({
            formType: 2,
            //value: '',
            title: '填写运费(非负数)'
        }, function(value, index, elem){
            //alert(value); //得到value
            $.ajax({
                url: "?id={{$info->id}}",
                type: 'post',
                dataType: 'json',
                data: { sequence: oid , freight:value, type:"accpet" },
                success: function (data) {
                    alert(data.msg);

                    history.back(-1);

                },
                error: function () {
                    alert('服务器繁忙..请稍后重试！');
                }
            });
            layer.close(index);
        });
    });

    $("#s2").click(function () {    //现金支付
        var oid = $("#oid").val();
        $.ajax({
            url: "/order/cash",
            type: 'post',
            dataType: 'json',
            data: { sequence: oid },
            success: function (data) {
                if(data.status==0)
                {
                    hrefto();
                }
                else
                {
                    alert(data.msg);
                }
            },
            error: function () {
                alert('服务器繁忙..请稍后重试！');
            }
        });
    });

    $("#s3").click(function () {    //发货
        var oid = $("#oid").val();
        layer.prompt({
            formType: 2,
            value: '快递:  运单号:',
            title: '填写快递公司与物流单号'
        }, function(value, index, elem){

            //alert(value); //得到value
            if( value.length < 15 )
            {
                layer.alert('不得少于15个字');
            }
            else
            {
                $.ajax({
                    url:"",
                    data:{id: {{$info->id}},logistics:value,type:'send'},
                    type:"post",
                    dataType:"json",
                    success:function(data){
                        if( data.status == 1 )
                        {
                            hrefto();
                        }
                        else
                        {
                            layer.alert(data.msg);
                        }
                    },
                    error:function(){
                        alert("请求失败");
                    }
                });
            }
            layer.close(index);
        });
        $('.layui-layer-input').click(function(){
          $(this).html('')
          $(".layui-layer-input").unbind();
        })
    });

    $("#s4").click(function () {    //取消

        var oid = $("#oid").val();
        $.ajax({
            url: "",
            type: 'post',
            dataType: 'json',
            data: { id: {{$info->id}} ,type:'cancel'},
            success: function (data) {
                if(data.status==1)
                {
                    hrefto();
                }
                else
                {
                    alert(data.msg);
                }
            },
            error: function () {
                alert('服务器繁忙..请稍后重试！');
            }
        });

    });

    $("#s5").click(function () {    //删除订单
        var oid = $("#oid").val();
        $.ajax({
            url: "/order/del",
            type: 'post',
            dataType: 'json',
            data: { sequence: oid },
            success: function (data) {
                if(data.status==0)
                {
                    hrefto();
                }
                else
                {
                    alert(data.msg);
                }
            },
            error: function () {
                alert('服务器繁忙..请稍后重试！');
            }
        });
    });


    $(".shanchu").click(function () {   //删除订单产品
        var ODid = $(this).attr("detail");
        var sequence = $("#oid").val();
        console.log(ODid + " / " +sequence);
        $.ajax({
            url: "",
            type: 'post',
            dataType: 'json',
            data: {id: {{$info->id}}, ODid: ODid, type: 'orderUpdate' },
            success: function (data) {
                if(data.status==1)
                {
                    alert("删除成功");
                    location.reload();
                }
                else
                {
                    alert(data.msg);
                }
            },
            error: function () {
                alert('服务器繁忙..请稍后重试！');
            }
        });
    });

    function hrefto() {
        var buyway = $("#buyway").val();
        if(buyway==0)
        {
            window.location.href = "/admin/order?ismobile=1&type=0";
        }
        else if(buyway==1)
        {
            window.location.href = "/admin/order?ismobile=1&type=1";
        }
    }

</script></body></html>
